package day13.KeJian;

import java.io.*;

public class ConversionStreamDemo {
    public static void main(String[] args) throws IOException {
        //InputStreamReader(InputStream in)使用默认字符编码创建InputStreamReader对象
        InputStreamReader ir = new InputStreamReader(new FileInputStream("D://itheima//nb.txt"),"GBK");
        //一次读取一个字符数据
        int ch;
        while ((ch=ir.read())!=-1){
            System.out.println((char)ch);
        }
        ir.close();

        //OutputStreamWriter(OutputStream out)使用默认字符编码创建OutputStreamWriter对象
        OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream("D://itheima//nb.txt"),"GBK");
        ow.write("中国");
        ow.close();
    }
}
